# -*- coding: utf-8 -*-
# Author: xiantingDeng
# File: 04_生成器.py
# Time: 20:45

# a = [x*2 for x in range(10)]
# print(a)
#
# b = (x *2 for x in range(10))
# print(b)
# print(next(b))
# print(next(b))
# print(next(b))
# print(next(b))
# print(next(b))
"""
def creatNum(numer):
    print("-------start-------")
    a, b = 0, 1
    for i in range(numer):
        print("_____1_____")
        yield b
        print("______2_____")
        a, b = b, a + b
        print("_______3________")
    print("-----stop-----")


# print(next(creatNum(100)))

a = creatNum(10)

# for num in a:
#     print(num)
# ret = a.__next__() # 等价于next(a)
# print(ret)
"""

"""
def tdest():
    i = 0
    while i < 5:
        temp = yield i
        print("2") 
        print(temp)
        i += 1


t = tdest()

print(t.__next__())
# t.send("hah s")
print(t.__next__())
print(t.__next__())


def test():
    i = 0
    while i < 5:
        if i == 0:
            temp = yield i
        else:
            yield i
        i += 1

t = test()

print(t.__next__())


"""

#
# def foo():
#     print("starting...")
#     while True:
#         res = yield 4
#         print("res:", res)
#
#
# g = foo()
# print(next(g))
# print("*" * 20)
# print(next(g))

"""

def foo():
    print("starting...")
    while True:
        res = yield 4
        print("res:", res)


g = foo()
print(next(g))
print("*" * 20)
print(g.send(7))
"""


#